﻿using System;
using Aspects.Custom;

namespace Aspects.Unit
{
    public class Battery
    {
        public void Update()
        {
            
        }
        
        /// <summary>
        /// Gets a value depending on the Embedded controller
        /// </summary>
        /// <param name="low">The low byte command to process</param>
        /// <param name="high">The high byte command to process</param>
        /// <returns></returns>
        private int GetValue(ushort low, ushort high)
        {
            var lowValue = ECPort.ReadEC(low);
            var highValue = ECPort.ReadEC(high);
            return (int)((highValue << 8) + lowValue);
        }

        private int GetValue(ushort command)
        {
            return (int)ECPort.ReadEC(command);
        }
        
        /// <summary>
        /// The event passed when a battery is unplugged
        /// </summary>
        /// <param name="battery">the number of the battery that was unplugged</param>
        public delegate void BatteryUnpluggedEventHandler(Battery source);
        /// <summary>
        /// The event passed whena  battery is plugged in
        /// </summary>
        /// <param name="battery">the number of the battery that was plugged in</param>
        public delegate void BatteryPluggedInEventHandler(Battery source);
        /// <summary>
        /// When a battery is unplugged this event is fired
        /// </summary>
        public event BatteryUnpluggedEventHandler BatteryUnplugged;
        /// <summary>
        /// When a battery is plugged in this event is fired
        /// </summary>
        public event BatteryPluggedInEventHandler BatteryPluggedIn;
    }
}
